# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-strategy/warzone2100/warzone2100-2.3.9.ebuild,v 1.7 2012/07/29 21:18:01 hasufell Exp $

EAPI=4

WANT_AUTOMAKE="1.11"

inherit autotools eutils versionator games git-2

VIDEOS_P=${PN}-videos-high-quality-en.wz
DESCRIPTION="3D real-time strategy game"
HOMEPAGE="http://wz2100.net/"
SRC_URI="videos? ( mirror://sourceforge/warzone2100/warzone2100/Videos/high-quality-en/sequences.wz -> ${VIDEOS_P} )"
EGIT_REPO_URI="https://github.com/Warzone2100/warzone2100.git"

LICENSE="GPL-2 CCPL-Attribution-ShareAlike-3.0 public-domain"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86"
# upstream requested debug support
IUSE="debug nls videos +qt"

RDEPEND="dev-db/sqlite:3
	>=dev-games/physfs-2[zip]
	media-libs/libogg
	media-libs/libpng
	!qt? ( media-libs/libsdl[opengl,video] )
	media-libs/libtheora
	media-libs/libvorbis
	media-libs/openal
	!qt? ( media-libs/sdl-net )
	media-libs/quesoglc
	media-libs/glew
	virtual/glu
	virtual/opengl
	nls? ( virtual/libintl )
	x11-libs/libXrandr
	dev-libs/fribidi
	media-libs/freetype
	media-libs/fontconfig
	x11-libs/qt-core
	x11-libs/qt-script
	qt? (
		x11-libs/qt-gui
		x11-libs/qt-opengl
	)"
DEPEND="${RDEPEND}
	sys-devel/bison
	app-arch/zip
	virtual/pkgconfig
	nls? ( sys-devel/gettext )
	app-text/asciidoc"
RDEPEND="${RDEPEND}
	media-fonts/dejavu"

src_prepare() {
	sed -i \
		-e 's/#top_builddir/top_builddir/' \
		po/Makevars || die

	eautoreconf
}

src_configure() {
	local backend=sdl
	use qt && backend=qt

	egamesconf \
		--disable-dependency-tracking \
		--docdir=/usr/share/doc/${PF} \
		--localedir=/usr/share/locale \
		--with-distributor="Gentoo ${PF}" \
		--with-icondir=/usr/share/pixmaps \
		--with-applicationdir=/usr/share/applications \
		--with-backend=${backend} \
		$(use_enable debug debug relaxed) \
		$(use_enable nls)
}

src_install() {
	emake DESTDIR="${D}" install || die
	rm -f "${D}"/usr/share/doc/${PF}/COPYING*
	if use videos ; then
		insinto "${GAMES_DATADIR}"/${PN}
		newins "${DISTDIR}"/${VIDEOS_P} sequences.wz || die
	fi
	doman doc/warzone2100.6
	prepgamesdirs
}
